var addOptions={
    top: 0, left: 0, width: 500,
    addCaption: "Добавить запись",
    bSubmit: "Сохранить",
    bCancel: "Отменить", 
    closeAfterAdd: true,
    closeOnEscape: true
};

jQuery("#bp_accept_filelist").GridUnload("#bp_accept_filelist");	
jQuery("#bp_accept_userlist").GridUnload("#bp_accept_userlist");	


rndid=$("#rndid").val();
jQuery("#bp_accept_filelist").jqGrid('setGridParam',{url:'controller/server/getfilesbp.php?randomid='+rndid});                
jQuery("#bp_accept_filelist").jqGrid('setGridParam',{editurl:'controller/server/getfilesbp.php?randomid='+rndid});                
jQuery("#bp_accept_filelist").jqGrid({
                        url:'controller/server/getfilesbp.php?randomid='+rndid,
                        datatype: "json",
                        colNames:['Id','Название','Имя файла','Действия'],
                        colModel:[
                            {name:'id',index:'id', width:55},
                            {name:'title',index:'title', width:100,editable:true},
                            {name:'filename',index:'filename', width:100},
                            {name:'myac',  width:80, fixed:true, sortable:false, resize:false, formatter:'actions',formatoptions:{keys:true},search: false}
   	],
        	autowidth: true,		
                rowNum:10,	
                rowList:[10,20,30],
                pager: '#bp_accept_filelist_buttom',
                sortname: 'id',
                scroll:1,
                viewrecords: true,
                sortorder: "asc",
                editurl:'controller/server/getfilesbp.php?randomid='+rndid,
                caption:"Прикрепленные файлы"
                }).trigger('reloadGrid');                                
                
                
jQuery("#bp_accept_userlist").jqGrid('setGridParam',{url:'controller/server/getbpuserslist.php?randomid='+rndid});                
jQuery("#bp_accept_userlist").jqGrid('setGridParam',{editurl:'controller/server/getbpuserslist.php?randomid='+rndid});                
                
jQuery("#bp_accept_userlist").jqGrid({
                        url:'controller/server/getbpuserslist.php?randomid='+rndid,
                        datatype: "json",
                        colNames:['Id','Участник','E-mail','Статус'],
                        colModel:[
                            {name:'id',index:'id', width:55},
                            {name:'userlogin',index:'userlogin', editable: true, width:100,edittype:"select",sortable:false,
                                editoptions:{
                                    editrules: { required: true },
                                    dataUrl: 'controller/server/listallusers.php'
                                    }                            
                            },
                            {name:'email',index:'email', width:100,sortable:false},
                            {name:'status',index:'status', width:100,sortable:false}
   	],
        	autowidth: true,		
                rowNum:10,	
                rowList:[10,20,30],
                pager: '#bp_accept_userlist_buttom',
                sortname: 'id',
                scroll:1,
                viewrecords: true,
                sortorder: "asc",
                editurl:'controller/server/getbpuserslist.php?randomid='+rndid,
                caption:"C кем согласовывать БП"
                }).trigger('reloadGrid');        
                //alert(status);
if (status==0)                
    {
        jQuery("#bp_accept_userlist").jqGrid('navGrid','#bp_accept_userlist_buttom',{edit:false,add:true,del:true,search:false},{},addOptions,{},{multipleSearch:false},{closeOnEscape:true} );
    } else
        {
          jQuery("#bp_accept_userlist").jqGrid('navGrid','#bp_accept_userlist_buttom',{edit:false,add:false,del:false,search:false},{},addOptions,{},{multipleSearch:false},{closeOnEscape:true} );
        }

                
var btnUpload=$('#uploadButton');
 var upload_me=new AjaxUpload(btnUpload, {
     action : 'controller/server/uploadfiles.php',
     name : 'myfile',
     onComplete: function(file, response){
       if(response!=""){
           //$('#status').text='ошибка..';           
           alert("Ошибка загрузки:"+response);
       } else {jQuery("#bp_accept_filelist").jqGrid().trigger('reloadGrid');};
   }
 });                